0%

Jupyter Notebook使用记录

Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果。

安装

1
pip install jupyterlab

使用

1
2
3
4
5
6
7
8
9
10
11
jupyter --help
jupyter notebook --help
jupyter notebook --help-all
jupyter notebook --generate-config 生成配置文件
jupyter notebook --port 指定端口,默认888
jupyter notebook --ip 指定ip,默认localhost
jupyter notebook --no-browser 启动时不打开浏览器
jupyter notebook password 设置密码

jupyter kernelspec list 查看内核
jupyter kernelspec remove {name} 删除内核

示例:

1
jupyter notebook --no-browser --ip 0.0.0.0 --port 8080

配置

设置访问密码:

1
2
3
4
5
> jupyter notebook password

Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to C:\Users\xxx\.jupyter\jupyter_notebook_config.json

添加内核:

1
2
3
workon py36_env
pip install ipykernel
python -m ipykernel install --name "py36env"

常用快捷键

模式 组合键 说明
编辑模式 Esc 切换到命令模式
命令模式 A 在当前Cell上方新建Cell
命令模式 B 在当前Cell下方新建Cell
命令模式 DD 删除当前单元
命令模式 Y 切换到Code状态
命令模式 M 切换到Markdown状态
命令模式 II 中断内核运行
命令模式 L 显示代码框中每行的数字标识
命令模式 shift + v 粘贴单元格
命令模式 shift + L 显示全部代码框中每行的数字标识
编辑模式 shift + Tab 查看当前函数的说明(光标要在函数的位置内)
命令/编辑模式 shift + enter 运行当前单元后,进入下一单元
命令/编辑模式 ctrl + enter 只运行当前单元,不进入下一单元

文档